<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    {% if title %}
        <title>{{ title }} - Microblog</title>
    {% else %}
        <title>Welcome to Microblog!</title>
    {% endif %}
</head>
<body>
    <div>
        Microblog:
        <a href="{{ url_for('index') }}">Home</a>
        <!-- 用户实例的is_anonymous属性是在其模型继承UserMixin类后Flask-Login添加的，
            表达式current_user.is_anonymous仅当用户未登录时的值是True -->
        {% if current_user.is_anonymous %}
            <a href="{{ url_for('login') }}">Login</a>
        {% else %}
            <a href="{{ url_for('user', username=current_user.username) }}">Profile</a>
            <a href="{{ url_for('logout') }}">Logout</a>
        {% endif %}
        <a href="{{ url_for('explore') }}">Explore</a>
    </div>
    
    <hr>
    {% with messages = get_flashed_messages() %}
        {% if messages %}
        <ul>
            {% for message in messages %}
            <li>{{ message }}</li>
            {% endfor %}
        </ul>
        {% endif %}
    {% endwith %}
    {% block content %}{% endblock %}
</body>
</html>